package com.xuetang9.controller.a;

import com.xuetang9.domain.User;
import com.xuetang9.vo.JsonResultVO;
import com.xuetang9.vo.a.MenuVO;
import com.xuetang9.vo.a.MenusVO;
import com.xuetang9.vo.a.SubVO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @工能
 * @作者 杜目杰
 * @时间 2020/5/19
 * @地点 公司
 * @版本 1.0.0
 * @版权 老九学堂
 */
@Controller
@CrossOrigin
@ResponseBody
public class MenuController {
    /**
     * 创建菜单
     * @return 菜单列表
     */
    @PostMapping("/getMenus")
    public MenusVO  listMenu(){
        String menuName[]  = {"我的工作台","系统管理","杆塔管理","线路管理","缺陷管理","巡检任务管理","消缺任务管理","信息统计"};
        String[] menuId={"100","200","300","400","500","600","700","800"};;
        String[][] subName ={
                {"待办列表","个人资料修改"},
                {"角色管理","用户管理","角色权限配置","系统配置",},
                {"杆塔管理"},
                {"线路管理"},
                {"缺陷类型设置","缺陷等级确认"},
                {"巡检任务制定与分配","巡检任务执行与回执","缺陷查询"},
                {"消缺任务制定与分配","消缺任务执行与回执","消缺查询"},
                {"巡检记录统计","消缺记录统计"}
        };
        String[][] subPath ={
                {"back","mean"},
                {"role","user","permission","system"},
                {"pinecone"},
                {"way"},
                {"defecttype","bugbar"},
                {"patroltaskformulation","patrolinspectioniscarriedout","defectsinthequery"},
                {"eliminatetaskformulation","eliminatetaskexecution","thequeryforgettingridof"},
                {"statisticsofinspectionrecords","eliminaterecordstatistics"}
        };
        JsonResultVO<User> jsonResultVO = new JsonResultVO<>();
        List<MenuVO> menuVOS = new ArrayList<>();
        MenusVO menusVO = new MenusVO();

        for(int i=0;i<menuName.length;i++){
            MenuVO menuVO = new MenuVO();
            menuVO.setId(menuId[i]);
            menuVO.setMenu(menuName[i]);
            List<SubVO> subVOS = new ArrayList<>();
            for(int j = 0 ; j < subName[i].length;j++ ){
                SubVO subVO = new SubVO();
                subVO.setPath(subPath[i][j]);
                subVO.setSubName(subName[i][j]);
                subVOS.add(subVO);
            }
            menuVO.setSub(subVOS);
            menuVOS.add(menuVO);
        }
        menusVO.setResult(menuVOS);
        return menusVO;
    }
}
